package com.egg.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.egg.action.common.BaseAction;
import com.egg.service.LoginService;
/**
 * @项目名称：egg   
 * @类名称：LoginAction   
 * @类描述：登录   
 * @创建人：wangchenyang
 * @创建时间：2012-9-4 上午9:41:52   
 * @修改人：
 * @修改时间：   
 * @修改备注：   
 * @version
 */
@ParentPackage("default")
@Namespace("/login")
public class LoginAction extends BaseAction{
	private static final long serialVersionUID = 1L;
	private List<Map<String,Object>> resultList;
	private String userAccount;
	private String userPassword;
	@Autowired
	LoginService loginService;
	
	@Action(value="login",results={@Result(name="success",location="/frame/index.jsp",type="redirect"),@Result(name="error",location="/login.jsp",type="redirect")})
	public String login(){
		resultList=loginService.loginEgg(getSession(), userAccount, userPassword);
		if(resultList!=null&&resultList.size()!=0){
			return "success";
		}else{
			return "error";
		}
	}

	@Action(value="logout",results={@Result(name="success",location="/login.jsp",type="redirect"),@Result(name="error",location="/login.jsp",type="redirect")})
	public String logout(){
		loginService.logoutEgg(getSession());
		return "success";
	}
	public List<Map<String, Object>> getResultList() {
		return resultList;
	}

	public void setResultList(List<Map<String, Object>> resultList) {
		this.resultList = resultList;
	}

	public String getUserAccount() {
		return userAccount;
	}

	public void setUserAccount(String userAccount) {
		this.userAccount = userAccount;
	}

	public String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

}
